
export function mrmColumns() {
  const COLUMN_WIDTH = window.RPConfig.COLUMN_WIDTH
  return [
    {
      type: "selection",
      align: "left",
      width: 50
    },
    {
      title: this.$t("module.resourceManage.resCode"),
      key: "resourceCode",
      ellipsis: true,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceCode,
              href: "#"
            }
          },
          params.row.resourceCode
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resName"),
      key: "resourceName",
      ellipsis: false,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceName,
              href: "#"
            }
          },
          params.row.resourceName
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resourceType"),
      key: "resourceType",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_6_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_6_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceType,
              href: "#"
            }
          },
          this.resourceType[params.row.resourceType - 1]
        );
      }
    },
    {
      title: this.$t("module.resourceManage.parentPath"),
      key: "parentResourceName",
      ellipsis: true,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourcePath, // 鼠标移入【父路径】时，会冒泡提示该资源所属的全部资源路径
              href: "#"
            }
          },
          params.row.parentResourceName // 该UI资源的父UI资源，或该API资源的父功能
        );
      }
    },
    {
      title: this.$t("module.valueSet.isPublic"),
      key: "publicFlag",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_4_WORDS,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_4_WORDS + COLUMN_WIDTH.MAX_WIDTH_MORE,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.publicFlag,
              href: "#"
            }
          },
          params.row.resourceType == 2
            ? params.row.publicFlag == 1
              ? this.$t("module.valueSet.public")
              : this.$t("module.valueSet.notpublic")
            : this.$t("module.valueSet.notpublic")
        );
      }
    },
    {
      title: this.$t('module.functionManage.permissionModel'),
      key: 'authType',
      render: (h, params) => {
        return h(
          'span',
          {},
          (() => {
            const item = this.authTypeList.find(item => item.vsiKey == params.row.authType)
            return (item && params.row.resourceType == 2) ? item.vsiValue : '--'
          })()
        )
      }
    },
    {
      title: this.$t("common.status"),
      key: "enabled",
      align: "center",
      minWidth: 80,
      maxWidth: 80 + COLUMN_WIDTH.MAX_WIDTH_MORE,
      render: (h, params) => {
        return h(
          "StatusButton",
          {
            // 修改StatusButton内容居中
            style: {
              "justify-content": "center"
            },
            props: {
              status: params.row.enabled == 1 ? "0" : "1"
            }
          },
          !!params.row.enabled ? this.$t("common.enable") : this.$t("common.disable")
        );
      }
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 90,
      render: (h, params) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: "md-create",
                text: this.$t("common.edit"),
                handle: () => {
                  this.edit(params.row);
                }
              },
              {
                type: "icon",
                icon: params.row.resourceType == 1 ? "ios-settings" : "",
                text: this.$t("module.resourceManage.assResour"),
                handle: () => {
                  this.assignResource(params.row);
                }
              },
              {
                type: "icon",
                icon: params.row.enabled == 1 ? "" : "md-trash",
                text: this.$t("common.delete"),
                handle: () => {
                  this.deleted(params.row);
                }
              }
            ]
          }
        });
      }
    }
  ];
}

export function copyColumns() {
  return [
    {
      type: "selection",
      align: "left",
      width: 50
    },
    {
      title: this.$t("module.resourceManage.resCode"),
      key: "resourceCode",
      ellipsis: true,
      width: 200,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceCode,
              href: "#"
            }
          },
          params.row.resourceCode
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resName"),
      key: "resourceName",
      ellipsis: false,
      width: 180,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceName,
              href: "#"
            }
          },
          params.row.resourceName
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resourceType"),
      key: "resourceType",
      width: 80,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceType,
              href: "#"
            }
          },
          this.resourceType[params.row.resourceType - 1]
        );
      }
    },
    {
      title: this.$t("module.resourceManage.ownerProduct"),
      key: "productId",
      // width: 240,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.productId,
              href: "#"
            }
          },
          params.row.productId
        );
      }
    }
  ];
}

export function assignApiColumns() {
  return [
    {
      type: "selection",
      align: "left",
      width: 50
    },
    {
      title: this.$t("module.resourceManage.resCode"),
      key: "resourceCode",
      ellipsis: true,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceCode,
              href: "#"
            }
          },
          params.row.resourceCode
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resName"),
      key: "resourceName",
      ellipsis: false,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceName,
              href: "#"
            }
          },
          params.row.resourceName
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resourceType"),
      key: "resourceType",
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceType,
              href: "#"
            }
          },
          this.resourceType[params.row.resourceType - 1]
        );
      }
    },
    {
      title: this.$t("module.resourceManage.application"),
      key: "applicationName",
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.applicationName,
              href: "#"
            }
          },
          params.row.applicationName
        );
      }
    },
    {
      title: this.$t("common.status"),
      key: "enabled",
      render: (h, params) => {
        return h(
          "StatusButton",
          {
            props: {
              status: params.row.enabled == 1 ? "0" : "1"
            }
          },
          !!params.row.enabled ? this.$t("common.enable") : this.$t("common.disable")
        );
      }
    }
  ];
}

export function selectApiColumns() {
  return [
    {
      type: "selection",
      align: "left",
      width: 50
    },
    {
      title: this.$t("module.resourceManage.resCode"),
      key: "resourceCode",
      ellipsis: true,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceCode,
              href: "#"
            }
          },
          params.row.resourceCode
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resName"),
      key: "resourceName",
      ellipsis: false,
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceName,
              href: "#"
            }
          },
          params.row.resourceName
        );
      }
    },
    {
      title: this.$t("module.resourceManage.resourceType"),
      key: "resourceType",
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.resourceType,
              href: "#"
            }
          },
          this.resourceType[params.row.resourceType - 1]
        );
      }
    },
    {
      title: this.$t("module.resourceManage.application"),
      key: "applicationName",
      render: (h, params) => {
        return h(
          "span",
          {
            attrs: {
              title: params.row.applicationName,
              href: "#"
            }
          },
          params.row.applicationName
        );
      }
    },
    {
      title: this.$t("common.status"),
      key: "enabled",
      render: (h, params) => {
        return h(
          "StatusButton",
          {
            props: {
              status: params.row.enabled == 1 ? "0" : "1"
            }
          },
          !!params.row.enabled ? this.$t("common.enable") : this.$t("common.disable")
        );
      }
    }
  ];
}
